package com.rd.student.ruanjian.class3.gaochenxi.ShunXu;

public class TestShunXun {

   public static void main(String[] args) {
      T1 t1 = new T1();
      T2 t2 = new T2(t1);
      T3 t3 = new T3(t2);
      t1.start();
      t2.start();
      t3.start();
   }
}

class T1 extends Thread {
   @Override
   public void run() {
      System.out.println("1");
   }

}

class T2 extends Thread {
   private T1 t1;

   public T2(T1 t1) {
      this.t1 = t1;
   }

   @Override
   public void run() {
      try {
         t1.join();
      } catch (InterruptedException e) {
         e.printStackTrace();
      }
      System.out.println("2");
   }

}

class T3 extends Thread {
   private T2 t2;

   public T3(T2 t2) {
      this.t2 = t2;
   }

   @Override
   public void run() {
      try {
         t2.join();
      } catch (InterruptedException e) {
         e.printStackTrace();
      }
      System.out.println("3");
   }
}
